package com.mfw.springboot.model.vo;

import com.mfw.springboot.model.entity.UserClassRelation;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 用户班级关系视图
 *
 * @author mfw
 * @from <a href="https://gitee.com/hanhuaifei/projects">我的gitee</a>
 * @Date 2024/9/26
 */
@Data
public class UserClassRelationVO implements Serializable {

    /**
     * id
     */
    private Long id;

    /**
     * 用户ID
     */
    private Long userId;

    /**
     * 班级ID
     */
    private Long classId;

    /**
     * 加入时间
     */
    private Date joinTime;

    /**
     * 角色: student/assistant
     */
    private String role;

    /**
     * 状态: active/exit
     */
    private String status;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;


    private static final long serialVersionUID = 1L;


    /**
     * 用户信息
     */
    private UserVO user;

    /**
     * 班级信息
     */
    private ClassInfoVO classInfo;

    /**
     * 封装类转对象
     *
     * @param userClassRelationVO
     * @return
     */
    public static UserClassRelation voToObj(UserClassRelationVO userClassRelationVO) {
        if (userClassRelationVO == null) {
            return null;
        }
        UserClassRelation userClassRelation = new UserClassRelation();
        BeanUtils.copyProperties(userClassRelationVO, userClassRelation);
        return userClassRelation;
    }

    /**
     * 对象转封装类
     *
     * @param userClassRelation
     * @return
     */
    public static UserClassRelationVO objToVo(UserClassRelation userClassRelation) {
        if (userClassRelation == null) {
            return null;
        }
        UserClassRelationVO userClassRelationVO = new UserClassRelationVO();
        BeanUtils.copyProperties(userClassRelation, userClassRelationVO);
        return userClassRelationVO;
    }
}
